package com.spicdt.edge.protocol.door.demo.callback.controller;


import com.spicdt.edge.protocol.door.demo.DoorProtocolService;
import com.spicdt.edge.protocol.door.demo.callback.dto.OpenApiResult;
import com.spicdt.edge.protocol.door.demo.callback.service.CallBackService;
import com.spicdt.edge.protocol.door.demo.callback.service.CallBackServiceImpl;
import com.spicdt.iedge.psdk.annotation.EnableSpringWebContext;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 描述: 回调控制器
 *
 * @author ZlTan
 * @date 2025/04/07 19:15
 */
@Slf4j
@RestController
@EnableSpringWebContext
@RequestMapping("/api/openApi/callBackByType")
public class CallBackController {

    @Autowired
    private DoorProtocolService protocolService;

    @PostMapping(value = "/${channelId}/{sourceId}")
    public OpenApiResult push(@PathVariable("sourceId") String sourceId,
                              @RequestBody String body) {

        log.info("接收参数{}，{}", sourceId, body);
        CallBackService callBackService = new CallBackServiceImpl(protocolService);
        return callBackService.push(sourceId, body);
    }


}
